package com.dc.free.util;

import javax.servlet.http.HttpSession;

/**
 * 单点信息
 * @author quan
 *
 */
public class SSOUtil {
	
	public static final String SSO_USER = "sso_user";

	/**
	 * 设置单点用户
	 * @param session
	 * @param user
	 */
	public static void setUser(HttpSession session, Object user) {
		session.setAttribute(SSO_USER, user);
	}
	
	/**
	 * 获取单点用户
	 * @param session
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static <T> T getUser(HttpSession session) {
		return (T) session.getAttribute(SSO_USER);
	}
	
	/**
	 * 判断单点用户是否存在
	 * @param session
	 * @return
	 */
	public static boolean isExistUser(HttpSession session) {
		if(getUser(session) == null)
			return false;
		return true;
	}
}
